package com.glodon.paas.document.dao.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.glodon.paas.document.api.bean.PublicToken;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;

@Entity(value = "part", noClassnameStored = true)
public class PublicTokenEntity {

    public static PublicToken getDto(PublicTokenEntity e) {
        if (e == null) {
            return null;
        } else {
            PublicToken d = new PublicToken();
            d.setFileId(e.getFileId());
            d.setPublishTime(e.getUpdateTime());
            d.setToken(e.getToken());
            d.setDatabagToken(e.getDatabagToken());
            return d;
        }
    }

    public static List<PublicToken> getDtos(List<PublicTokenEntity> es) {
        if (es == null) {
            return null;
        } else {
            List<PublicToken> ds = new ArrayList<PublicToken>();
            for (PublicTokenEntity e : es) {
                ds.add(getDto(e));
            }
            return ds;
        }
    }

    @Id
    private String fileId;

    private String token;

    private Date   updateTime;

    private String ownerId;

    private String databagToken;

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }

    public String getDatabagToken() {
        return databagToken;
    }

    public void setDatabagToken(String databagToken) {
        this.databagToken = databagToken;
    }

}
